
<script>
/*
 * 参考github element-ui源码【cascader-node】
 * https://github.com/ElemeFE/element/blob/dev/packages/cascader-panel/src/cascader-node.vue
*/
import cascaderNode from '@cci/city-ui/packages/cascader-panel/src/cascader-node.vue'

export default {
  name: 'CascaderNode',
  extends: cascaderNode,
  data () {
    return {
    }
  },

  computed: {},

  mounted () {},

  methods: {
    renderContent (h) {
      const { panel, node } = this
      const render = panel.renderLabelFn
      const vnode = render
        ? render({ node, data: node.data })
        : null
      return (
        <span class="el-cascader-node__label" onClick={ this.handleNodeLabelClick }>{ vnode || node.label }</span>
      )
    },
    handleNodeLabelClick () {
      const { config, node } = this
      const { checkStrictly, multiple } = config
      // 多选
      if (multiple) {
        this.handleMultiCheckChange(!node.checked)
      } else if (checkStrictly) {
        // 严格的遵守父子节点不互相关联
        this.handleCheckChange()
        this.panel.$parent.dropDownVisible = false
      }
    }
  }
}

</script>
